home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / TCP_IP / TNOS230S / NRS.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-24  |  1.6 KB  |  58 lines

  1. #ifndef    _NRS_H
  2. #define    _NRS_H
  3.  
  4. #ifndef    _GLOBAL_H
  5. #include "global.h"
  6. #endif
  7.  
  8. #ifndef    _MBUF_H
  9. #include "mbuf.h"
  10. #endif
  11.  
  12. #ifndef    _IFACE_H
  13. #include "iface.h"
  14. #endif
  15.  
  16. #define NRS_MAX 5        /* Maximum number of Nrs channels */
  17.  
  18. /* SLIP definitions */
  19. #define    NRS_ALLOC    40    /* Receiver allocation increment */
  20.  
  21. #ifndef STX
  22. #define STX    0x02        /* frame start */
  23. #endif
  24. #define ETX 0x03        /* frame end */
  25. #define DLE    0x10        /* data link escape */
  26. #define NUL 0x0            /* null character */
  27.  
  28. /* packet unstuffing state machine */
  29. #define NRS_INTER    0        /* in between packets */
  30. #define NRS_INPACK    1        /* we've seen STX, and are in a the packet */
  31. #define NRS_ESCAPE    2        /* we've seen a DLE while in NRS_INPACK */
  32. #define NRS_CSUM    3        /* we've seen an ETX, and are waiting for the checksum */
  33.  
  34. /* net/rom serial protocol control structure */
  35. struct nrs {
  36.     char state;        /* Receiver State control flag */
  37.     unsigned char csum;    /* Accumulating checksum */
  38.     struct mbuf *rbp;    /* Head of mbuf chain being filled */
  39.     struct mbuf *rbp1;    /* Pointer to mbuf currently being written */
  40.     char *rcp;        /* Write pointer */
  41.     int16 rcnt;        /* Length of mbuf chain */
  42. #if 0
  43.     struct mbuf *tbp;    /* Transmit mbuf being sent */
  44. #endif
  45.     long errors;        /* Checksum errors detected */
  46.     long packets ;        /* Number of packets received successfully */
  47.     struct iface *iface ;    /* Associated interface structure */
  48.     int (*send) (int,struct mbuf *);/* Routine to send mbufs */
  49.     int (*get) (int);/* Routine to fetch input chars */
  50. };
  51.  
  52. extern struct nrs *Nrs;
  53. /* In nrs.c: */
  54. int nrs_raw (struct iface *iface,struct mbuf *bp);
  55. void nrs_recv (int dev,void *v1,void *v2);
  56.  
  57. #endif    /* _NRS_H */
  58.